 class password extends RuntimeException{
     public password() {
         super();
     }

     public password(String message) {
         super(message);
     }
 }

 class username extends RuntimeException{
     public username() {
         super();
     }

     public username(String message) {
         super(message);
     }
 }

public class Test3 {
    private String userName = "admin";
    private String password = "123456";
    public  void loginInfo(String user, String password) throws username,password{
        if(!this.userName.equals(user)){
            throw new username("用户名错误");
        }
        if(!this.password.equals(password)){
            throw new password("密码错误");
        }
        System.out.println("登录成功");
    }

    public static void main(String[] args) {
        Test3 test3 = new Test3();
        try {
            test3.loginInfo("admin","12345");
        }catch (username e){
            e.printStackTrace();
            System.out.println("UserNameException");
        }catch (password e){
            e.printStackTrace();
            System.out.println("PasswordException");
        }

    }
}
